Answer:

First    23.5
Second   45.1

Replacing a Variable's Contents with a Result

The contents of a variable can come from the result of a calculation. You can use a result to replace the contents of a variable. Look at the following program:

' Which earns the most money? 
' 40 hours at $5 an hour, or
' 30 hours at $6 an hour
' 
LET RATE = 5
LET HOURS = 40
LET PAY = HOURS * RATE  
PRINT "Pay for ", HOURS, "hours at ", RATE, " = " , PAY
'
LET RATE = 6
LET HOURS = 30
LET PAY = HOURS * RATE  
PRINT "Pay for ", HOURS, "hours at ", RATE, " = " , PAY 
'
END

Here is how the first half of the program works:

  1. Memory is found for RATE, and 5 is stored there.
  2. Memory is found for HOURS, and 40 is stored there.
  3. The third LET statement:
    • Finds memory for PAY.
    • Uses the value 40 in HOURS.
    • Uses the value 5 in RATE.
    • Performs the calculation 40 * 5.
    • Stores the result, 200, in PAY.
  4. The PRINT statement:
    • Writes Pay for
    • Looks in HOURS, gets the 40, and writes it.
    • Writes hours at
    • Looks in RATE, gets the 5, and writes it.
    • Writes =.
    • Looks in PAY, gets 200, and writes it.

At this point computer memory looks like:

RATE
5
HOURS
40
PAY
200

QUESTION 21:

What does the first half of the program print to the screen?